/*
    This file is part of p4f
    Copyright (C) 2009  Sebastian Fernandez

    p4f is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as 
    published by the Free Software Foundation, either version 3 of the 
    License, or (at your option) any later version.

    p4f is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
*/

#ifndef _THREAD_H_
#define _THREAD_H_


#include <native.h>

//Thread proxy outside class scope for compatibility
#ifdef _WIN32
DWORD _stdcall thread_proxy(void *t);
#else
void *thread_proxy(void *t);
#endif

class Thread{
public:
	Thread();
	//Thread(void *(*function)(void *), void *args);
	virtual ~Thread();
	
	virtual void run(void *)=0;

	void start();
	void wait();
	void kill();

protected:
#ifdef _WIN32
	/* Windows threads */
	HANDLE  hThreadArray;
	DWORD   dwThreadIdArray;
#else 
	/* Posix threads*/
	pthread_t threads;
#endif
};

#endif /* _THREAD_H_ */
